package com.qf.pay.app.controller;

import com.qf.pay.app.pojo.AppUser;
import com.qf.pay.app.service.AppUserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.stereotype.Service;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.servlet.ModelAndView;

import javax.servlet.http.HttpSession;

@Controller
@RequestMapping("/user")
public class AppUserController {

    @Autowired
    private AppUserService appUserService;

    @RequestMapping("login")
    public ModelAndView login(String username, String password, HttpSession session) {
        AppUser appUser = appUserService.doLogin(username, password);
        if (appUser == null) {
            return new ModelAndView("/login.jsp", "message", "用户名或密码错误");
        }
        session.setAttribute("SESSION_USER", appUser);
        return new ModelAndView("/index.jsp");
    }
}
